package cn.onecloud.tablet.xiaozhi.net;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.widget.Toast;

import cn.onecloud.tablet.xiaozhi.BaseActivity;
import cn.onecloud.tablet.xiaozhi.util.NetworkUtil;

/**
 * Created by yin.he on 11/29/17.
 */
public class NetStateReceiver extends BroadcastReceiver {

    public NetStateReceiver() {

    }

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
            Toast.makeText(context, "network changed", Toast.LENGTH_LONG).show();
            BaseActivity.isNetWorkConnected = NetworkUtil.getAPNType(context) > 0;
        }
    }
}